package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.entity.FixedAssetLabel;
import com.amsp.oa.oademo.service.FixedAssetLabelService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/fixed-asset-label")
@CrossOrigin
@Api(tags = "固定资产标签管理")
public class FixedAssetLabelController {

    @Autowired
    private FixedAssetLabelService fixedAssetLabelService;

    @PostMapping("/save")
    @ApiOperation("保存固定资产标签")
    public boolean save(@RequestBody FixedAssetLabel fixedAssetLabel) {
        return fixedAssetLabelService.saveOrUpdate2(fixedAssetLabel);
    }

    @GetMapping("/list")
    @ApiOperation("分页查询固定资产标签列表")
    public Page<FixedAssetLabel> list(
            @RequestParam(defaultValue = "1") Integer current,
            @RequestParam(defaultValue = "10") Integer size) {
        return fixedAssetLabelService.list(current, size);
    }

    @GetMapping("/{id}")
    @ApiOperation("获取固定资产标签详情")
    public FixedAssetLabel getById(@PathVariable Long id) {
        return fixedAssetLabelService.getById2(id);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除固定资产标签")
    public boolean delete(@PathVariable Long id) {
        return fixedAssetLabelService.delete2(id);
    }
}